import { createRouter, createWebHistory } from "vue-router"
import Index from "../views/Index.vue"

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "Index",
      component: Index
    },
    {
      path: "/404",
      hidden: true,
      component: () => import("../views/404.vue")
    },
    {
      path: "/login",
      name: "Login",
      component: () => import("../views/account/login.vue")
    },
    {
      path: "/register",
      name: "Register",
      component: () => import("../views/account/register.vue")
    },
    {
      path: "/home",
      name: "Home",
      component: () => import("../views/home/home.vue")
    },
    {
      path: "/category/:categoryId",
      name: "Category",
      component: () => import("../views/catalog/category.vue")
    },
    {
      path: "/category/:categoryId/:productId",
      name: "Product",
      component: () => import("../views/catalog/product.vue")
    },
    {
      path: "/category/:categoryId/:productId/:itemId",
      name: "Item",
      component: () => import("../views/catalog/item.vue")
    },
    {
      path: "/search/:searchText",
      name: "Search",
      component: () => import("../views/catalog/search.vue"),
      redirect: (to) => {
        return { path: "/search", name: "SearchList", params: { searchText: to.params.searchText } }
      }
    },
    {
      path: "/cart",
      name: "Cart",
      component: () => import("../views/cart/cart.vue")
    },
    {
      path: "/account",
      name: "Account",
      component: () => import("../views/account/account.vue")
    },
    {
      path:"/order",
        name:"Order",
      component: () => import("../views/order/order.vue")
    },

    {}
  ]
})

export default router
